<?php
class ModuleFeatured extends AppModel
{
	var $name = 'ModuleFeatured';
	var $useTable = false;
	var $fieldProperties = array(
			'category_id' => array(
				'type' => 'select', 
				'empty' => '-Select-',
				'group' => array('add','edit'),
				'label' => 'Select Category', 
				'options' => array(),
				'style'=>'width: 150px;',
				'triggers' => array('onChange' => array('update' => 'listing_id', 'from_model' => 'ModuleFeatured')),				
				'validate'=>VALID_NOT_EMPTY,
				'class' => 'featured_module_category'
			),
			'listing_id' => array(
				'type' => 'select',
				'empty' => '-Select-',
				'group' => array('add','edit'),
				'label' => "Select Listing",
				'style'=>'left: 250px; width: 150px;',
				'validate'=>VALID_NOT_EMPTY,
				'tooltip' => 'Listings'
			),
			'listing_image' => array(
				'type' => 'file',					
				'group' => array('add','edit'),
				'style'=>'left: 550px; width: 250px;',
				'validate'=>VALID_NOT_EMPTY
			)
				
	);
	
	function initialize()
	{
		$categories = cri('ListCategory')->getOptions();
		$this->fieldProperties['category_id']['options'] = $categories;
		/*
		$this->fieldProperties['image_name'] = array(
				'type' => 'hidden',
				'group' => array('add','edit')				
		);
		*/
		$this->fieldProperties['category_id']['label']= __('Select Category');
		$this->fieldProperties['category_id']['dynamicoptionurl'] = '/cms/getOptions/ModuleFeatured.category_id/';
		$this->fieldProperties['listing_id']['label']= __('Select Listing');
		$this->fieldProperties['listing_image']['label']= __('Listing Image');
		
		parent::initialize();
	}
	
	function getListingIdOptions($category)
	{
		$conditions = array('list_category_id' => $category,'status'=>1);
		$ListingObj = cri("Listing");
		$tmp = $ListingObj->find('list', compact('conditions'));
		$tmp[0]=__('-Select-');
		return $tmp;
	}
}
?>
